package com.nbsaas.boot.shop.data.entity;

import com.nbsaas.boot.code.annotation.FieldConvert;
import com.nbsaas.boot.code.annotation.FieldName;
import com.nbsaas.boot.code.annotation.FormAnnotation;
import com.nbsaas.boot.code.annotation.SearchItem;
import com.nbsaas.boot.jpa.data.entity.LongEntity;
import com.nbsaas.boot.rest.filter.Operator;
import lombok.Data;
import org.hibernate.annotations.Comment;

import javax.persistence.*;

@Data
@FormAnnotation(title = "商家第三方登录")
@Entity
@Table(name = "bs_shop_token")
public class ShopOauthToken extends LongEntity {


    @Comment("用户id")
    private Long customerId;


    @Comment("访问token")
    private String accessToken;
    /**
     * 刷新token
     */

    @Comment("刷新token")
    private String refreshToken;

    /**
     * token类型
     */
    @Comment("token类型")
    private String tokenType;

    /**
     * 用户id
     */
    @Comment("用户openId")
    private String openId;

    @Comment("用户unionId")
    private String unionId;


    @Comment("过期时间")
    private Long expiresTime;


    @Comment("登录次数")
    private Integer loginSize;


    @SearchItem(label = "商家", name = "shop", key = "shop.id", operator = Operator.eq, classType = Long.class, show = false)
    @Comment("商家id")
    @JoinColumn(name = "shop_id")
    @FieldConvert
    @FieldName
    @ManyToOne(fetch = FetchType.LAZY)
    private Shop shop;

}
